/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package application;

import java.awt.Color;
import java.awt.Component;
import javax.swing.*;
import javax.swing.border.Border;

/**
 *
 * @author Hui
 */
public class IconListItemRenderer extends JLabel implements ListCellRenderer
        {
            private Border
                selectedBorder = BorderFactory.createLineBorder(Color.blue,1),
                emptyBorder = BorderFactory.createEmptyBorder(1,1,1,1);

            public Component getListCellRendererComponent(
                        JList list,
                        Object value,
                        int index,
                        boolean isSelected,
                        boolean cellHasFocus)
                {

                IconListItem item = (IconListItem)value;
                this.setIcon(item.getIcon());
                this.setText(item.getText());

                if ( isSelected ) setBorder (selectedBorder);
                else setBorder(emptyBorder);
                
                return this;
            }
        }

